package es.urjc.adrh.reading;

import java.lang.reflect.Field;

import es.urjc.adrh.injection.LeaveNull;

@Author(name="Gasol")
public class TestClass {

	@LeaveNull
	String atributeTest; 
	
	@Author(name="Calderon")
	public String getTittle(){
		return "Requiem for a dream";
	}
	
	//Accessing to the annotation information using reflection
	public static void main (String [] args) throws SecurityException, NoSuchMethodException, NoSuchFieldException, IllegalArgumentException, IllegalAccessException{
		TestClass b = new TestClass();
		
		
		
		Author classAuthor = b.getClass().getAnnotation(Author.class);
		System.out.println("The author of the class "+ b.getClass() + " is " + classAuthor.name());
		System.out.println("This class has inside the next method: " );
		
		Author methodAuthor = b.getClass().getMethod("getTittle").getAnnotation(Author.class);
		System.out.println(" - " + b.getClass().getMethod("getTittle") + " programmed by " + methodAuthor.name());
	}
}
